package com.sm.graduation.dormitory.dao;

import java.util.List;
import java.util.Map;

import com.sm.graduation.echarts.dto.Biscuits;
import org.apache.ibatis.annotations.*;
import com.sm.graduation.dormitory.pojo.DormitoryAllocation;

@Mapper
public interface DormitoryAllocationMapper {

	List<DormitoryAllocation> listAll(Map map);


	@Select("select id,dormitory,living,name from dormitory_allocation where id=#{id}")
	DormitoryAllocation getById(Long id);


	@Insert("insert into dormitory_allocation(dormitory,living,name) values(#{dormitory},#{living},#{name})")
	int insert(DormitoryAllocation dormitoryAllocation);

	@Update("update dormitory_allocation set dormitory=#{dormitory}, living=#{living}, name=#{name} where id=#{id}")
	int update(DormitoryAllocation dormitoryAllocation);


	@Delete("delete from dormitory_allocation where id=#{id}")
	int delete(Integer id);

	@Select("SELECT count(id) from dormitory_allocation a where a.living = '1'")
	Long selectCount1();

	@Select("SELECT count(id) from dormitory_allocation a ")
	Long selectCount3();

	@Select(" SELECT count(a.id) from visitor a where a.vi_time >=#{start} and a.vi_time <=#{end}")
	Long selectCount2(String start,String end);

	@Select("  SELECT count(a.cost) from monthly_catering a  where a.mon_time >=#{star} and a.mon_time  <=#{end}")
	Long selectCount4(String star, String end);

	@Select("SELECT count(a.usr_sex) as value,a.usr_sex as name from usr_info a  group by a.usr_sex")
	List<Biscuits> table1();

	@Select("SELECT count(a.id) as value,a.medication as name from medication a  group by a.medication")
	List<Biscuits> table3();

	@Select("SELECT count(a.cost) as value,a.mon_time  as name from monthly_catering a  group by a.mon_time ORDER BY a.mon_time desc limit 30")
	List<Biscuits> table4();

	@Select("select a.cost as value ,a.year as name from check_in a ORDER BY a.year desc limit 15")
	List<Biscuits> table2();
}
